def cal_section_sum(ls_a, ls_b):
    # 前缀和
    n = len(ls_a)
    prefix_sum = [0] * (n + 1)  # 前n个元素相加的和，n=0,1,2...
    for i in range(1, n + 1):
        prefix_sum[i] = prefix_sum[i - 1] + ls_a[i - 1]
    for i in ls_b:
        a, b = i[0], i[1]
        result = prefix_sum[b] - prefix_sum[a - 1]
        print(result)



n = int(input())
ls_a = list(map(int,input().split()))
ls_b = []
m = int(input())
for i in range(m):
    tuple_c = tuple(map(int,input().split()))  # 将输入的区间转为元组
    ls_b.append(tuple_c)         # 将元组添加到列表中

cal_section_sum(ls_a,ls_b)